package model.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

import model.ConfigData;

/**
 * Connection pool for database
 * @author Potseluev
 *
 */
public class ConnectionPool {
	
	private static Connection _connection = null;
	
	public static Connection getConnection() throws Exception {
		
		if (_connection == null) {
			//System.setProperty("java.net.preferIPv4Stack" , "true"); //force use ipv4. Uses for Oracle virtual box
			Properties props = new Properties();
			props.setProperty("user",ConfigData.CONNECTIONUSER);
			props.setProperty("password",ConfigData.CONNECTIONPASSWORD);
			//props.setProperty("ssl","true");
			_connection = DriverManager.getConnection(ConfigData.CONNECTIONSTRING, props);
		} else {
			// must verify connection
		}
		
		return _connection;
	}

}
